﻿@using Huirui.Cavan.Domain.MainBoundedContext.StockModule
@model Huirui.Cavan.Presentation.ViewModel.StockModule.IStockViewModel
@{
    Layout = null;
}
@using (Html.BeginForm(ActionConst.ADD, ControllerConst.STOCK))
{
    <div class="tool_bar">
        <input id="stock_save" type="submit" style="display: none;" />
        <input id="stock_reset" type="reset" style="display: none" />
        <a href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-save'" onclick="javascript:$('#stock_save').click()">保存</a>
        <a href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-add'">新增</a>
        <a href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-undo'" onclick="javascript:$('#stock_reset').click()">重置</a>
        <a href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-search'" onclick="addTab('库存列表','center_tt','@Url.Action(ActionConst.LIST, ControllerConst.STOCK)')">查询</a>
        <a href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-print'">打印</a>
        <a href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-collapse'" onclick="toggleHeard()">折叠/展开</a>
    </div>
    <table class="form_heard">
        <tr>
            <td class="c100">
                <label class="BlueRequired">存货编号:</label>
            </td>
            <td class="c160">
                @Html.TextBoxFor(m => m.NoPrefixId, new { id = "stock_NoPrefixId" })
                @Html.TextBoxFor(m => m.Item.Id, new { id = "stock_id", style = "display: none;" })
            </td>
            <td class="c100">
                <label class="BlueRequired">存货性质:</label>
            </td>
            <td class="c160">
                @Html.DropDownListFor(m => m.Item.Nature, typeof(StockIdentifier.StockNature), new { id = "stock_nature"})
            </td>
        </tr>
        <tr>
            <td class="c100">
                <label class="BlueRequired">存货名称:</label>
            </td>
            <td class="c160">
                @Html.TextBoxFor(m => m.Item.Name, new { id = "stock_name" })
            </td>
            <td class="c100">
                <label>规格型号:</label>
            </td>
            <td class="c160">
                @Html.TextBoxFor(m => m.Item.Specification, new { id = "stock_specification" })
            </td>
        </tr>
        <tr>
            <td class="c100">
                <label class="BlueRequired">存货类别:</label>
            </td>
            <td class="c160">
                @Html.DropDownListFor(m => m.Item.Type.Id, Model.StockTypes, new { id = "stock_stocktype" })
            </td>
            <td class="c100">
                <label>默认存货地点:</label>
            </td>
            <td class="c160">
                @Html.DropDownListFor(m => m.Item.WareHouse.Id, Model.WareHouses, new { id = "stock_warehouse" })
            </td>
        </tr>
        <tr>
            <td class="c100">
                <label class="BlueRequired">主单位名称:</label>
            </td>
            <td class="c160">
                @Html.DropDownListFor(m => m.Item.UnitTransfer.FromUnit.Id, Model.StockUnitsForFrom, new { id = "stock_fromUnit" })
            </td>
            <td class="c100">
                <label>辅助单位名称:</label>
            </td>
            <td class="c160">
                @Html.DropDownListFor(m => m.Item.UnitTransfer.ToUnit.Id, Model.StockUnitsForTo, new { id = "stock_toUnit" })
            </td>
        </tr>
        <tr>
            <td class="c100">
                <label>主换算单位:</label>
            </td>
            <td class="c160">
                @Html.TextBoxFor(m => m.Item.UnitTransfer.FromNumber, new { id = "stock_fromNumber" })
            </td>
            <td class="c100">
                <label>辅助换算单位:</label>
            </td>
            <td class="c160">
                @Html.TextBoxFor(m => m.Item.UnitTransfer.ToNumber, new { id = "stock_toNumber" })
            </td>
        </tr>
        <tr>
            <td class="c100">
                <label>条形码:</label>
            </td>
            <td class="c160">
                @Html.TextBoxFor(m => m.Item.BarCode, new { id = "stock_barcode" })
            </td>
            <td class="c100">
                <label>受托代销商品:</label>
            </td>
            <td class="c160">
                @Html.DropDownListFor(m => m.Item.IsProxy, typeof(StockIdentifier.StockIsProxy), new { id = "stock_isproxy" })
            </td>
        </tr>
    </table>
    <fieldset>
        <legend>存量/价格</legend>
        <table class="form_heard">
            <tr>
                <td class="c100">
                    <label>标准买价:</label>
                </td>
                <td class="c160">
                     @Html.TextBoxFor(m => m.Item.StandardPurchasePrice, new { id = "stock_standardpurchaseprice" })
                </td>
                <td class="c100">
                    <label>最高采购限价:</label>
                </td>
                <td class="c160">
                    @Html.TextBoxFor(m => m.Item.MaxPurchasePrice, new { id = "stock_maxpurchaseprice" })
                </td>
            </tr>
            <tr>
                <td class="c100">
                    <label>标准卖价:</label>
                </td>
                <td class="c160">
                     @Html.TextBoxFor(m => m.Item.StandardSalesPrice, new { id = "stock_standardsalesprice" })
                </td>
                <td class="c100">
                    <label>最低销售限价:</label>
                </td>
                <td class="c160">
                     @Html.TextBoxFor(m => m.Item.MinSalesPrice, new { id = "stock_minsalesprice" })
                </td>
            </tr>
              <tr>
                <td class="c100">
                    <label>最低存量:</label>
                </td>
                <td class="c160">
                     @Html.TextBoxFor(m => m.Item.MinLeftNumber, new { id = "stock_minleftnumber" })
                </td>
                <td class="c100">
                </td>
                <td class="c160">
                </td>
            </tr>
        </table>
    </fieldset>
    <fieldset>
        <legend class="left_right_bord_0">记账规则</legend>
        <div class="customer_div">
            <label>增值税税率:</label>
            @Html.TextBoxFor(m => m.Item.TaxRate, new { id = "stock_taxrate" })<label>%</label>
        </div>
    </fieldset>
}
<fieldset>
    <legend>维护其它信息</legend>
    <div class="customer_div">
        <a>采购信息维护</a>
        <a>销售信息维护</a>
        <a>初始余额维护</a>
    </div>
</fieldset>
@{ Html.RenderAction(ActionConst.ADD, ControllerConst.STOCKTYPE, new { Purpose = "ForStock", CmbName = "select#stock_stocktype" }); }
<script type="text/javascript">
    $(function ()
    {
        $("form[action^='/stock/add']").submit(function ()
        {
            $.ajax({
                url: this.action,
                type: this.method,
                data: $(this).serialize(),
                success: function (data)
                {
                    if (data.IsSuccess)
                    {
                        alert(data.Messages[0]);
                    }
                },
                error: function ()
                {
                    alert('系统繁忙，请稍候再试');
                }
            })

            return false;
        });
    });

    $("select#stock_stocktype").bind("change", function ()
    {
        if ($('select#stock_stocktype').val() == "0")
        {
            openWindow("addStockTypeWindowForStock");
        }
    });
</script>
